package com.errorfinding.tabbitmqDemo.consumer;


import cn.hutool.core.date.DateUtil;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 死信消费者
 * 队列ttl 消费者
 */
@Component
public class DeadLetterQueueConsumer {

    //接收消息
    // queues 队列名称
    @RabbitListener(queues = "qd")
    /**
     * 参数1。接收内容
     * 参数2。信道
     */
    public void receiveD(Message message, Channel channel) throws Exception {
        String msg = new String(message.getBody(),"UTF-8");
        System.out.println("当前时间："+ DateUtil.date()+"，收到死信队列的消息："+msg);
    }

}
